<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.prime.com.tr/ui"
	template="../templates/template.xhtml">

	<ui:define name="content">
		<h:form id="logform">
			<div align="right">
				<h:commandLink>

					<p:graphicImage value="/images/pdf.png" style="border:none" />
					<p:dataExporter type="pdf" target="logdatatable"
						fileName="logtable" pageOnly="true" />

				</h:commandLink>
				<br />
			</div>
			<p:dataTable id="logdatatable" var="logEntry"
				value="#{lazyLogBean.lazyModel}" paginator="true" rows="20"
				lazy="true"
				paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
				rowsPerPageTemplate="10,20,50,100"
				selection="#{lazyLogBean.selectedLogEntry}" selectionMode="single"
				resizableColumns="true">

				<p:ajax event="rowSelect" update=":logform:display"
					oncomplete="logDialog.show()" />

				<f:facet name="header">
					<p:outputPanel>
						<h:panelGrid columns="4" cellpadding="2">
							<h:outputLabel for="#{lazyLogBean.searchPattern}"
								value="Search messages: " />
							<h:inputText id="searchText" value="#{lazyLogBean.searchPattern}"
								label="Search messages: ">
							</h:inputText>
							<!--  <p:watermark for="searchText" value="Message" />-->
							<h:commandButton type="submit" value="Search"
								action="#{lazyLogBean.searchPattern}"></h:commandButton>
						</h:panelGrid>

					</p:outputPanel>
				</f:facet>

				<p:column headerText="Time" sortBy="#{logEntry.time}"
					style="width:150px">
					<h:outputText value="#{logEntry.time}">
						<f:convertDateTime pattern="dd.MM.yyyy HH:mm:ss"
							timeZone="Europe/Berlin" />
					</h:outputText>
				</p:column>

				<p:column headerText="Type">
					<h:outputText value="#{logEntry.type}" />
				</p:column>

				<p:column headerText="User">
					<h:outputText value="#{logEntry.user.name}" />
				</p:column>

				<p:column headerText="Line">
					<h:outputText value="#{logEntry.line.name}" />
				</p:column>

				<p:column headerText="Message" style="width:600px"
					filterMatchMode="contains">
					<h:outputText value="#{logEntry.message}" />
				</p:column>
			</p:dataTable>

			<p:dialog header="Log Details" widgetVar="logDialog"
				resizable="false" height="300" width="400" modal="true">

				<h:panelGrid id="display" columns="2" cellpadding="4">

					<f:facet name="header">
					</f:facet>

					<h:outputText value="Type:" />
					<h:outputText value="#{lazyLogBean.selectedLogEntry.type}" />

					<h:outputText value="Time:" />
					<h:outputText value="#{lazyLogBean.selectedLogEntry.time}">
						<f:convertDateTime pattern="yyyy.MM.dd 'at' HH:mm:ss z"
							timeZone="Europe/Berlin" />
					</h:outputText>
					<h:outputText value="User:" />
					<h:outputText value="#{lazyLogBean.selectedLogEntry.user.name}" />

					<h:outputText value="Line:" />
					<h:outputText value="#{lazyLogBean.selectedLogEntry.line.name}" />

					<h:outputText value="Message:" />
					<h:outputText value="#{lazyLogBean.selectedLogEntry.message}" />



				</h:panelGrid>
			</p:dialog>

		</h:form>

	</ui:define>

</ui:composition>